<template>
	<view>
		<view class="cflex-c u-p-25 cbg-zhuti">
			<view class="cflex-r u-m-b-15" style="justify-content: space-between;align-items: center;">
				<image src="../../static/my/big.png" mode=""style="width: 764rpx;height: 352rpx;position: relative;"></image>
				<view class="cflex-c" style="position: absolute;color: #FFFFFF;width: 702rpx;justify-content: center;align-items: center;">
					<view class="cflex-r">
						<text style="font-weight: bold;">当前金额 (元)</text>
					</view>
					<view style="margin: 30rpx 0; font-size: 60rpx;">
						<text>{{balance}}</text>
					</view>
					
					<view>
						<text>{{content}}</text>
					</view>
				</view>
			</view>
			
				<view class="cflex-r" style="background-color: #FFFFFF;border-radius: 15rpx;padding: 30rpx;align-items: center;justify-content: space-between;">
					<input v-model="Ti_balance" min="0" type="number" placeholder="请输入提现金额" @input="moneyXS()"/>
					<view style="background-color: #2869FE;padding: 10rpx 10rpx;border-radius: 15rpx;" @tap="allMoney()">全部提现</view>
				</view>
				
				<view style="background-color: #2869FE;margin-top: 20rpx;text-align: center;padding: 20rpx 0;border-radius: 15rpx;" @tap="tiXianClick()">提现</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				balance: 0,
				Ti_balance:'',
				content:'',
			}
		},
		onShow() {
			this.myQianBao();
		},
		onLoad(options) {
			
		},
		methods: {
			moneyXS(){
				let money = this.Ti_balance.toString().match(/^\d*(\.?\d{0,2})/g)[0];
				setTimeout(()=>{
					this.Ti_balance = money;
				},10);
				
			},
			allMoney(){
				this.Ti_balance = this.balance;
			},
			myQianBao(){
				this.$request("worker/tixian/getMyMoney").then(res=>{
					console.log("金额===========>",res);
					this.balance = res.data.money;
					this.content = res.data.tiXianMoney;
				})
			},
			tiXianClick(){
				if(!this.Ti_balance){
					uni.showToast({
						title:"请输入提现金额",
						icon:"none",
						duration:2000
					})
				}else if(this.balance<this.Ti_balance){
					uni.showToast({
						title:"提现金额不能超出当前金额",
						icon:"none",
						duration:2000
					})
				}
				else {
					this.$request("worker/tixian/tiXian",{money:this.Ti_balance}).then(res=>{
						// //console.log(this.Ti_balance);
						console.log("提现之后========>",res);
						if(res.code==0){
							this.Ti_balance = '';
							uni.showModal({
								title:"提示",
								content:"提现成功,请等待审核...",
								showCancel:false,
								success: function (res) {
									if (res.confirm) {
										console.log('用户点击确定');
										uni.navigateBack({
											delta:1
										})
									}
								}
							})
						}else {
							uni.showToast({
								title:"提现失败",
								icon: "none"
							})
						}
					})
				}
			}
		}
	}
</script>

<style>

</style>
